//
//  SecurityMessage.m
//  LocomotiveGuards
//
//  Created by xys on 15/11/21.
//  Copyright (c) 2015年 REDOOR. All rights reserved.
//

#import "SecurityMessage.h"

@implementation SecurityMessage

+ (instancetype) SecurityMessageWithMessageDict:(NSDictionary *) msg
{
    SecurityMessage * securityMessage = [[SecurityMessage alloc]init];
    
    securityMessage.msgString = msg[@"msg"];
    NSString * time = msg[@"time"];
    NSDate * date = [NSDate dateWithTimeIntervalSince1970:time.doubleValue/1000];
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"yyyy年MM月dd日";
    securityMessage.dateString = [formatter stringFromDate:date];
    
    NSString * typeString = msg[@"type"];
    securityMessage.msgType = typeString.integerValue;
    
    return securityMessage;
}
@end
